#include"list.h"

void print(const list<int>& lt){
	list<int>::const_iterator it = lt.begin();
	while(it != lt.end()){
		cout << *it << " ";
		++it;
	}
	cout << "\n";
}

//测试尾插和迭代器
void test1(){
	list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	list<int>::iterator it = lt.begin();
	while(it != lt.end()){
		cout << *it << " ";
		++it;
	}
	cout << "\n";
}
//测试插入和删除
void test2(){
	list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);
	lt.push_front(44);
	print(lt);
	int a = 10;
	list<int>::iterator it = lt.begin();
	while(it != lt.end()){
		a += 10;
		lt.insert(it, a);
		it++;
	}
	print(lt);
	lt.erase(lt.begin());
	lt.pop_back();
	lt.pop_front();
	print(lt);
}

//测试拷贝构造和赋值重载
void test3(){
	list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);
	lt.push_front(44);
	print(lt);
	list<int> lt2(lt);
	print(lt2);
	lt2.push_back(3);
	lt = lt2;
	print(lt);
}

int main(){
	//test1();
	//test2();
	test3();
	return 0;
}